1. Field of the Invention
The present invention relates generally to an improved data processing system and in particular to a computer implemented method and apparatus for processing data. Still more particularly, the present invention relates to a computer implemented method, apparatus, and computer usable program code for collecting and processing data during the execution of code.
2. Description of the Related Art
In writing code, runtime analysis of the code is often performed as part of an optimization process. Runtime analysis is used to understand the behavior of components or modules within the code using data collected during the execution of the code. The analysis of the data collected may provide insight to various potential misbehaviors in the code. For example, an understanding of execution paths, code coverage, memory utilization, memory errors and memory leaks in native applications, performance bottlenecks, and threading problems are examples of aspects that may be identified through analyzing the code during execution.
The performance characteristics of code may be identified using a software performance analysis tool. The identification of the different characteristics may be based on a trace facility of a trace system. A trace tool may be used using various techniques to provide information, such as execution flows as well as other aspects of an executing program. A trace may contain data about the execution of code. For example, a trace may contain trace records about events generated during the execution of the code. A trace also may include information, such as, a process identifier, a thread identifier, and a program counter. Information in the trace may vary depending on the particular profiling or analysis that is to be performed. A record is a unit of information relating to an event that is detected during the execution of the code.
Profiling is a process performed to extract regular and reoccurring operations or events present during the execution of code. Many different types of events may be profiled. For example, the time spent in a task or section of code, memory allocation, and most executed instructions. The results of profiling are used to optimize or increase the performance of software. Oftentimes profiling may be used to tune or improve performance of a particular piece of software for a specific processor.
Typically, profiling is performed using the processor's own resources. These resources are often disturbed by the profiling code as the profiling code executes on the processor. The processor's caches and pipelines are shared by the application and the profiling code, which introduces changes to the processor's resources and the measurements collected by the profiling code. An example of a particular type of profiling with this problem is an instruction trace, which takes an exception on branches or on each instruction. It would be desirable, if during tracing, the resources being recorded were not affected by tracing. For example, allowing reporting of cache misses or any other performance monitoring metric by a routine would be a great enhancement to this type of tool. Similarly, a JAVA profiler, as described in U.S. Pat. No. 6,539,339, also referred to as jprof, would be significantly enhanced if the processing of this tool did not affect the processor's resources as the application or system is being profiled. Jprof uses event based support, getting control on entries to and exits from methods. Jprof gets the current value of a performance monitor counter on each entry and exit. The counter values could include completed instructions or cycles, which would be the metrics to be applied to the active method. Since any performance monitor counter could be used, these metrics are referred to as the collected data. These tools both provide a mechanism to rollup performance counter information by method and call stack by thread. Similarly, other code could be profiled and the same information could be applied to subroutines/functions. However, with the current profiling techniques, the usefulness of these tools are diminished because the use of processor resources to perform profiling functions affects the processor's resources.